<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // class 是一个定义类的语法糖 其功能就相当于构造函数
        function Person(name) {
            this.name = name
            this.dance = function() {
                console.log('跳舞')
            }
        }
        Person.prototype.say = function() {
            console.log('德玛西亚')
        }
        var person = new Person('王豪')

        class Person2 {
            constructor(name) {
                this.name = name
                this.dance = function() {
                    console.log('跳舞')
                }
            }

            say() {
                console.log('德玛西亚')
            }
        }


        Person2.prototype.talk = function() {
            console.log('敌军还有30秒到达战场')
        }
        var person2 = new Person2('王豪')

        console.log(person, person2)
        // person.say()
        // person2.dance()
    </script>
</body>
</html>